

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Default UML to XSD Mappings [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Code Engineering,Code Engineering XML Schema (XSD), Default UML To XSD Mappings,Default,Default UML To XSD Mappings,UML,UML Mappings To XSD">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Default UML to XSD Mappings</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="abstract_xsd_models.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="generate_xsd.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_BodyText"><span class="f_BodyText">The following table describes the default mapping of UML to XSD constructs. This set of mappings is useful when defining simple schemas from abstract Class models. The defaults are also assumed by the schema generator when generating unstereotyped elements in an abstract model. The </span><span class="f_UIControl">XML Schema</span><span class="f_BodyText"> pages of the Enterprise Architect UML </span><span class="f_UIControl">Toolbox</span><span class="f_BodyText"> (and UML Profile for XSD) override these default mappings through the use of stereotypes and Tagged Values.</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 5px 0px 5px 13px;"><table cellspacing="0" cellpadding="0" border="0" style="border: none; border-spacing:0px; border-collapse: collapse;">
<tr style="text-align:left;vertical-align:top;">
<td valign="top" width="165" bgcolor="#e3e6ed" style="width:165px; background-color:#e3e6ed; border: solid 1px #000000;"><p class="p_Tableheader"><span class="f_Tableheader">UML Construct</span></p>
</td>
<td valign="top" width="694" bgcolor="#e3e6ed" style="width:694px; background-color:#e3e6ed; border: solid 1px #000000;"><p class="p_Tableheader"><span class="f_Tableheader">Default XSD Production Rules</span></p>
</td>
</tr>
<tr style="text-align:left;vertical-align:top;">
<td valign="top" width="165" style="width:165px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext" style="font-style: italic;">Package</span></p>
</td>
<td valign="top" width="694" style="width:694px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext">A schema </span><span class="f_Tabletext">element</span><span class="f_Tabletext"> is generated for the target package. If the target package includes Classes from another package, which has the Tagged Values </span><span class="f_Tabletext" style="font-style: italic;">targetNamespace</span><span class="f_Tabletext"> and </span><span class="f_Tabletext" style="font-style: italic;">targetNamespacePrefix</span><span class="f_Tabletext"> set, these are included as attributes of the schema element.</span></p>
<p class="p_Tabletext"><span class="f_Tabletext">In addition, an </span><span class="f_Tabletext" style="font-style: italic;">import</span><span class="f_Tabletext"> or </span><span class="f_Tabletext" style="font-style: italic;">include</span><span class="f_Tabletext"> element is created for each referenced package. (An</span><span class="f_Tabletext" style="font-style: italic;"> include</span><span class="f_Tabletext"> element is used if the external package shares the same </span><span class="f_Tabletext" style="font-style: italic;">targetNamespace</span><span class="f_Tabletext"> Tagged Value as the target package. An </span><span class="f_Tabletext" style="font-style: italic;">import</span><span class="f_Tabletext"> element is used where the </span><span class="f_Tabletext" style="font-style: italic;">targetNamespaces</span><span class="f_Tabletext"> differ).</span></p>
</td>
</tr>
<tr style="text-align:left;vertical-align:top;">
<td valign="top" width="165" style="width:165px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext" style="font-style: italic;">Class</span></p>
</td>
<td valign="top" width="694" style="width:694px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext">A root-level </span><span class="f_Tabletext">element</span><span class="f_Tabletext"> declaration and </span><span class="f_Tabletext" style="font-style: italic;">complexType</span><span class="f_Tabletext"> definition are generated. The element </span><span class="f_Tabletext">name</span><span class="f_Tabletext"> and </span><span class="f_Tabletext">type</span><span class="f_Tabletext"> are the same as the Class name. An XSD </span><span class="f_Tabletext">sequence</span><span class="f_Tabletext"> model group is generated to contain UML attributes generated as elements.</span></p>
</td>
</tr>
<tr style="text-align:left;vertical-align:top;">
<td valign="top" width="165" style="width:165px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext" style="font-style: italic;">Attribute</span></p>
</td>
<td valign="top" width="694" style="width:694px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext">An </span><span class="f_Tabletext">element</span><span class="f_Tabletext"> is declared for each Class attribute. The element </span><span class="f_Tabletext">name</span><span class="f_Tabletext"> is set to that of the UML attribute name. This is prefixed with the Class name to make the element unique. The </span><span class="f_Tabletext" style="font-style: italic;">minOccurs</span><span class="f_Tabletext"> and </span><span class="f_Tabletext" style="font-style: italic;">maxOccurs</span><span class="f_Tabletext"> attributes are set to reflect the attribute cardinality.</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 4px 2px 4px 2px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" bgcolor="#efeff7" style="background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td bgcolor="#f7f7ff" style="background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">If left unspecified, </span><span class="f_TiporNoteText" style="font-style: italic;">minOccurs</span><span class="f_TiporNoteText"> and </span><span class="f_TiporNoteText" style="font-style: italic;">maxOccurs</span><span class="f_TiporNoteText"> default to </span><span class="f_TiporNoteText" style="font-weight: bold;">1</span><span class="f_TiporNoteText">.</span></p>
</td>
</tr>
</table>
</div>
<p class="p_Tabletext"><span class="f_Tabletext">If the attribute refers to another Class, the element declaration is followed a </span><span class="f_Tabletext" style="font-style: italic;">complexType</span><span class="f_Tabletext"> definition, which contains a reference to the appropriate </span><span class="f_Tabletext" style="font-style: italic;">complexType</span><span class="f_Tabletext">.</span></p>
</td>
</tr>
<tr style="text-align:left;vertical-align:top;">
<td valign="top" width="165" style="width:165px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext" style="font-style: italic;">Association</span></p>
</td>
<td valign="top" width="694" style="width:694px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext">An </span><span class="f_Tabletext">element</span><span class="f_Tabletext"> is declared for each association owned by a Class. The element </span><span class="f_Tabletext">name</span><span class="f_Tabletext"> is set to that of the association role. The </span><span class="f_Tabletext" style="font-style: italic;">minOccurs</span><span class="f_Tabletext"> and </span><span class="f_Tabletext" style="font-style: italic;">maxOccurs</span><span class="f_Tabletext"> reflect the cardinality of the association.</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 4px 2px 4px 2px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" bgcolor="#efeff7" style="background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td bgcolor="#f7f7ff" style="background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">If the direction of the association is unspecified, the owner is assumed to be the source.</span></p>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr style="text-align:left;vertical-align:top;">
<td valign="top" width="165" style="width:165px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext" style="font-style: italic;">Generalization</span><span class="f_Tabletext"> (Inheritance)</span></p>
</td>
<td valign="top" width="694" style="width:694px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext">For single inheritances, an </span><span class="f_Tabletext">extension</span><span class="f_Tabletext"> element is generated with the </span><span class="f_Tabletext">base</span><span class="f_Tabletext"> attribute set to the base Classname. The UML attributes of the child Class are then appended to an </span><span class="f_Tabletext">all</span><span class="f_Tabletext"> model group within the extension element.</span></p>
</td>
</tr>
<tr style="text-align:left;vertical-align:top;">
<td valign="top" width="165" style="width:165px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext" style="font-style: italic;">&laquo;enumeration&raquo;</span><span class="f_Tabletext"> (stereotype)</span></p>
</td>
<td valign="top" width="694" style="width:694px; border: solid 1px #000000;"><p class="p_Tabletext"><span class="f_Tabletext">A </span><span class="f_Tabletext" style="font-style: italic;">simpleType</span><span class="f_Tabletext"> element is declared for the enumeration Class with the </span><span class="f_Tabletext">name</span><span class="f_Tabletext"> attribute set to the Classname. A </span><span class="f_Tabletext">restriction </span><span class="f_Tabletext">element is generated with </span><span class="f_Tabletext">base</span><span class="f_Tabletext"> set to </span><span class="f_Tabletext">string</span><span class="f_Tabletext">. Each of the Class attributes is appended to the restriction element as XSD </span><span class="f_Tabletext">enumeration</span><span class="f_Tabletext"> elements with value set to the UML attribute name. Any type specification for the UML attributes is ignored by the schema generator.</span></p>
</td>
</tr>
</table>
</div>




            </div>
          </div>
        </div>



</div>


</body>
</html>
